package jooq;

import org.jooq.codegen.GenerationTool;
import org.jooq.meta.jaxb.Configuration;
import org.jooq.meta.jaxb.Database;
import org.jooq.meta.jaxb.Generate;
import org.jooq.meta.jaxb.Generator;
import org.jooq.meta.jaxb.Jdbc;
import org.jooq.meta.jaxb.Target;
import org.junit.Test;

import java.io.File;

public class JooqGen {
    @Test
    public void t2() throws Exception {
        Configuration c = new Configuration().withJdbc(new Jdbc().
                withUrl("jdbc:mysql://127.0.0.1:3306/wordpress2").
                withUsername("root").withDriver("com.mysql.jdbc.Driver").withSchema("wordpress2").
                withPassword("123456")).withGenerator(new Generator().withGenerate(
                        new Generate().withDaos(true).withJpaAnnotations(true).withSpringAnnotations(true))
                .withDatabase(
                        new Database().withIncludes(".*").withInputSchema("wordpress2")).
                        withTarget(new Target().withPackageName("jooq.wp").withDirectory("target/generated-sources/jooq-mysql")));
        GenerationTool.generate(c);
    }

    @Test
    public void t1() throws Exception {
        String path = Thread.currentThread().getClass().getResource("/").getPath();
        System.out.println(path);
        GenerationTool.main(new String[]{path + File.separator + "library.xml"});
    }
}
